<?php
header("Content-type:text/html; charset=utf-8" );
$conn =mysql_connect('localhost','root','')
or die('数据库无法连接');
mysql_select_db('neu-video',$conn)
or die('数据库不存在');
mysql_set_charset('utf8');
//mysql_query('set names utf8');
$sql='select * from videos';
$result=mysql_query($sql,$conn);
/*while ($result &&($row=mysql_fetch_assoc($result))!==FALSE) {
	echo $row['uname'].'<br>';
	# code...
}*/
$videos=fetch_array($result);
//var_dump($users);

$sqlstring="select t1.*from videos t1 left join videotype t2 t1.tid=t2.tid";
$result=mysql_query($sql,$conn);
$videos=fetch_array($result);
echo '<table border="1">';


echo '<caption>视频管理</caption>';
echo '<tr><th>视频ID</th><th>视频名称</th><th>视频类型</th><th>海报</th><th>内容简介</th><th>添加日期</th><th>上传用户</th><th>点击率</th><th>下载量</th><th>下载地址</th>';
foreach ($videos as $one ) {
	echo '<tr>';
	echo '<td>'.$one['vid'].'</td>';
	echo '<td>'.$one['videoname'].'</td>';
	echo '<td>'.$one['tid'].'</td>';
	echo '<td>'.$one['pic'].'</td>';
	echo '<td>'.$one['intro'].'</td>';
	echo '<td>'.$one['uploaddate'].'</td>';
	echo '<td>'.$one['uploadadmin'].'</td>';
	echo '<td>'.$one['hittimes'].'</td>';
	echo '<td>'.$one['downtimes'].'</td>';
	echo '<td>'.$one['address'].'</td>';
	echo '</tr>';# code...
}

echo '</table>';
function fetch_array($results){
	$arrs=array();
	while ($results &&($row=mysql_fetch_assoc($results))!==FALSE) {
	$arrs[]=$row;
}
	return $arrs;

}

?>
